#ifndef __MQTT_H__
#define __MQTT_H__

#include "stdlib.h"
#include "stdint.h"
#include "stdbool.h"

typedef enum
{

	MQTT_DATA_VOICE_TYPE    = 0,
	MQTT_DATA_BUSINESS_TYPE = 1,

}MQTT_TYPE_t;


typedef enum
{
    MQTT_VOICE_TYPE_STATUS_FIRST_FRAME    = 0,
    MQTT_VOICE_TYPE_STATUS_CONTINUE_FRAME = 1,
    MQTT_VOICE_TYPE_STATUS_LAST_FRAME =     2,

}MQTT_FUNC_VOICE_Code_t;

typedef struct 
{
	uint8_t type;
	uint8_t code;
	uint8_t *data;
	uint16_t len;

}Send_Msg_t;

typedef struct{

   bool is_connect;

  unsigned char user_name[50];
  unsigned char passwd[50];
	uint16_t port;
	uint8_t IP[4];
	
	unsigned char Subscribed_topic[5][50];
	unsigned char Published_topic[5][50];

}MQTT_Config_t;

extern MQTT_Config_t mqtt_config;


uint8_t Transport_Open(void);

uint8_t Transport_Close(void);



void MQTT_Connect(char *username, char *password);
void MQTT_Subscribe( char *topic,int req_qos);
void MQTT_Unsubscribe(char *topic);
//void MQTT_Publish(char *topic, int qos, char *payload);
void MQTT_Publish(char *topic, int qos, char *data,uint32_t data_len);
void MQTT_Pingreq(void);
void MQTT_Disconnect(void);
void msgDeal(unsigned char *msg, int len);

void MQTT_Recevice_callback(uint8_t *data_buffer,uint32_t len);
void MQTT_Send_Publish(uint8_t type ,uint8_t func_code,uint8_t *data,uint32_t len);



#endif
